﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using SDFL.Windows;

namespace SysCounterSpy
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException);
            
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmMainForm());
        }

        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs args)
        {
            SDFL.ExceptionHandling.ExceptionManagerImpl exHandler = new SDFL.ExceptionHandling.ExceptionManagerImpl();
            exHandler.HandleException(args.Exception.Message);
            Application.Exit();
        }

        private static void AppDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            SDFL.ExceptionHandling.ExceptionManagerImpl exHandler = new SDFL.ExceptionHandling.ExceptionManagerImpl();
            exHandler.HandleException(args.ExceptionObject.ToString());
            Application.Exit();
        }


    }
}
